package com.coolingme.buffered;

import java.io.*;

/**
 * 缓冲字符型流 基础用法
 *
 * @author wangyue
 * @date 2019/4/3 13:58
 */
public class BufferedReaderTest {

    public static void main(String[] args) {
        File file = new File("D://Java//IntelliJIDEA//workspace//java-learn//IO//file//fileBuffered//bufferedReader.txt");//文件对象
        String path = "D://Java//IntelliJIDEA//workspace//java-learn//IO//file//fileBuffered//copy//bufferedReader.txt";
        FileReader in = null;
        FileWriter out = null;
        BufferedReader bin = null;
        BufferedWriter bout = null;
        try {
            in = new FileReader(file);
            out = new FileWriter(path);

            bin = new BufferedReader(in);//高级流以低级流为基础
            bout = new BufferedWriter(out);

            String value = bin.readLine();// 直接读取一行的信息
            while (value != null) {
                System.out.println(value);
                bout.write(value);
                bout.newLine();//写一行行分隔符。
                bout.flush();
                value = bin.readLine();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            //关闭流
        }
    }

}
